<template>
	<!--会议管理-->
	<div>
		<div class="search-wrap d-flex a-center">
			<public-search
				:fields="fields"
				:search-param="form"
				@on-query="onQuery"
				@on-reset="onReset"
			/>
			<el-divider direction="vertical" class="m-b10" />
			<el-button
				color="#fc7037"
				style="color: #ffffff"
				class="m-b10"
				size="large"
				@click="onExport"
				>导出</el-button
			>
		</div>
		<public-table
			index
			:page="page"
			:tableData="tableData"
			:tableOption.sync="tableOption"
			@page-change="onPageChange"
		>
			<template #buttons="scope">
				<el-button
					color="#ff7b56"
					style="color: #ffffff"
					size="large"
					@click="handleView(scope.row)"
					>查看</el-button
				>
			</template>
		</public-table>
	</div>
</template>

<script setup>
import PublicTable from "@/components/PublicTable.vue";
import { onMounted, reactive, ref } from "vue";
import { tableCommonFun } from "@/hooks/tableCommon";
import PublicSearch from "@/components/PublicSearch.vue";
import { ElDivider } from "element-plus";
import { consoleApi } from "@/api/investment";

const interfaceConfig = reactive({
	fileName: "investment",
	apiPath: "meetingsManagementApi.pageMeetings",
});

const exportConfig = reactive({
	fileName: "investment",
	apiPath: "meetingsManagementApi.exportMeetings",
	tableName: "会议表",
});

const {
	form,
	page,
	tableOption,
	tableData,
	onQuery,
	onReset,
	onPageChange,
	getData,
	onExport,
} = tableCommonFun(interfaceConfig, exportConfig);

form.value = {
	projectId: "",
	keyword: "",
};

tableOption.value = [
	{ label: "会议编号 ", prop: "meetingId", minWidth: 100 },
	{ label: "会议名称", prop: "meetingName", minWidth: 100 },
	{ label: "项目名称", prop: "projectName", minWidth: 100 },
	{
		label: "会议类型",
		prop: "meetingType",
		formatter: (val) => {
			return (
				{
					"785629734177951051": "立项会议",
					"-6962400106587402897": "招标会议",
					"1635420940115396428": "投资会议",
					"5719436876726159658": "用章用印会议",
				}[val] || "-"
			);
    },
    minWidth: 100
	},
	{ label: "会议时间", prop: "dateTime", minWidth: 100 },
	{ label: "申请人", prop: "applicantName", minWidth: 100 },
	{ label: "所属部门", prop: "createDepartmentName", minWidth: 100 },
	{ label: "创建时间", prop: "createTime", minWidth: 100 },
	{ label: "创建人", prop: "createUserName", minWidth: 100 },
	{
		label: "操作",
		prop: "buttons",
		slot: true,
		width: 200,
	},
];

const fields = ref([
	{
		type: "input",
		label: "会议名称",
		key: "keyword",
		placeholder: "请输入会议名称",
		clearable: true,
	},
	{
		type: "select",
		label: "所属项目",
		key: "projectId",
		placeholder: "请选择项目项目",
		clearable: true,
		options: {
			labelKey: "projectName",
			valueKey: "projectId",
			list: [],
		},
	},
]);

/**
 * 获取所有项目信息
 *
 */
const getList = () => {
	consoleApi.projectInvestment({}).then((res) => {
		if (res.code == 200) {
			fields.value[1].options.list = res.data;
		}
	});
};
const handleView = (row) => {
	window.open(row.oaUrl);
};

onMounted(() => {
	getList();
	getData({
		pageNum: 1,
		pageSize: 50,
		param: {},
	});
});
</script>

<style scoped></style>
